package com.jswlw.service.biz.impl;

import com.jswlw.dao.biz.DevSetMapper;
import com.jswlw.entity.biz.DevSet;
import com.jswlw.service.biz.DevSetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author 吴维斌 E-mail:wuweibin0817@163.com
 * @version 创建时间：${date} ${time}
 */
@Service
public class DevSetServiceImpl implements DevSetService {
    @Autowired
    DevSetMapper mapper;

    @Override
    public void add(DevSet devSet) {
        mapper.insert(devSet);
    }

    @Override
    public void update(DevSet devSet) {
        mapper.updateByPrimaryKey(devSet);
    }

    @Override
    public DevSet find4DevId(String devId) {
        DevSet devSet = mapper.find4DevId(devId);
        if (Objects.isNull(devSet)) {
            //新增数据
            devSet = new DevSet();
            devSet.setDevId(devId);
            devSet.setLl2sc(10);
            devSet.setPumpWorkTime(90);
            devSet.setWashTime(18);
            devSet.setWashFixedTime(360);
            devSet.setServiceTime(360);
            devSet.setOneWaterOfTime(10);
            mapper.insert(devSet);
        }
        return mapper.find4DevId(devId);
    }
}
